package com.koron.ticket.work.workdescription.controller;

import com.koron.bean.base.Response;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.ticket.work.workdescription.bean.WorkDescription;
import com.koron.ticket.work.workdescription.service.WorkDescriptionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("work/workdescription")
@Api(tags = "两票管理-工作票-备注管理")
public class WorkDescriptionController {

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @Autowired
    private WorkDescriptionService workDescriptionService;

    @PostMapping("insert")
    @ApiOperation("新增备注，没有工作票id的情况下会报错")
    public Response insert(@RequestBody WorkDescription workDescription) {
        return ADOConnection.runTask(getCurrDs(),workDescriptionService,"insert", Response.class, workDescription);
    }

    @GetMapping("getListByWorkTicketId")
    @ApiOperation("获取当前工作票下的所有备注,没有工作票id的情况下会报错")
    public Response getListByWorkTicketId(@RequestParam String workTicketId) {
        return ADOConnection.runTask(getCurrDs(),workDescriptionService,"getListByWorkTicketId", Response.class, workTicketId);
    }

}
